﻿using ACServerApi.Extensions;
using TypeScriptProxyGenerator;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace ACServerApi.Models
{
    [TSGen(TSGenTag.ClientModel)]
    [IniSettingsAttribute("SERVER")]
    public class ACConfigServer : ACConfigBase
    {
        public ACConfigServer()
        {
            // Default values
            this.ClientSendInterval = 15;
            PortUdp = 9600;
            PortTcp = 9600;
            PortHttp = 8081;
            this.SleepTime          = 1;
            this.BlacklistMode      = 0;
            this.LoopMode           = true;
            this.RegisterToLobby    = true;
            this.SunAngle           = -8;
            this.RaceOvertime       = 20;
            this.VotingQuorum       = 75;
            this.VoteDuration       = 20;
            this.KickQuorum         = 30;
            this.TCAllowed          = 1;
            this.AbsAllowed         = 1;
            this.StabilityAllowed   = false;
            this.AutoclutchAllowed  = true;
            this.DamageMultipier    = 0;
            this.FuelRate           = 100;
            this.AllowedTiresOut    = -1;
            this.TireWearRate       = 100;
            this.TireBlanketsAllowed= true;

        }

        [IniSettingsAttribute("NAME")]
        [DisplayName("Name")]
        [Description("Name of the server shown in the lobby")]
        public string Name { get; set; }

        [IniSettingsAttribute("PASSWORD")]
        [DisplayName("Password")]
        [Description("Server password")]
        public string Password { get; set; }

        [IniSettingsAttribute("ADMIN_PASSWORD")]
        [DisplayName("Admin Password")]
        [Description("It's the password needed to be recognized as server administrator. Write on the game's chat /help to see the command list")]
        public string AdminPassword { get; set; }

        [IniSettingsAttribute("CLIENT_SEND_INTERVAL_HZ")]
        [DisplayName("Refresh Rate")]
        [Description("refresh rate of packet sending by the server. 10Hz = ~100ms. Higher number = higher MP quality = higher bandwidth resources needed. Really high values can create connection issues")]
        public int ClientSendInterval { get; set; }

        [IniSettingsAttribute("UDP_PORT")]
        [DisplayName("Port UDP")]
        [Description("UDP port number between 9000 and 10000 -> open this port on your server's firewall")]
        public int PortUdp { get; set; }

        [IniSettingsAttribute("TCP_PORT")]
        [DisplayName("Port TCP")]
        [Description("TCP port number between 9000 and 10000 -> open this port on your server's firewall")]
        public int PortTcp { get; set; }

        [IniSettingsAttribute("HTTP_PORT")]
        [DisplayName("Port HTTP")]
        [Description("Lobby port number -> open this ports (both UDP and TCP) on your server's firewall")]
        public int PortHttp { get; set; }

        [IniSettingsAttribute("SLEEP_TIME")]
        [DisplayName("Sleep Time")]
        [Description("This must not be touched")]
        public int SleepTime { get; private set; }

        [IniSettingsAttribute("BLACKLIST_MODE")]
        [DisplayName("Blacklist enabled")]
        [Description("ban player -> 0 = for session duration, 1 = until server restart, 2 = forever (client's GUID is inserted into blacklist.txt)")]
        public int BlacklistMode { get; set; }

        [IniSettingsAttribute("LOOP_MODE")]
        [DisplayName("Loop Mode")]
        [Description("the server restarts from the first track, to disable this set it to 0")]
        public bool LoopMode { get; set; }

        [IniSettingsAttribute("REGISTER_TO_LOBBY")]
        [DisplayName("Register to lobby")]
        [Description("")]
        public bool RegisterToLobby { get; private set; }

        [IniSettingsAttribute("MAX_CLIENTS")]
        [DisplayName("Maximum Players")]
        [Description("max number of clients (must be <= track's number of pits)")]
        public int MaxClients { get; set; }

        [IniSettingsAttribute("PICKUP_MODE_ENABLED")]
        [DisplayName("Pickup Mode")]
        [Description("")]
        public bool PickupMode { get; set; }

        [IniSettingsAttribute("CARS")]
        [DisplayName("Cars")]
        [Description("Allowed cars on this server")]
        public List<ACCar> Cars { get; set; }

        [IniSettingsAttribute("TRACK")]
        [DisplayName("Tracks")]
        [Description("Allowed tracks on this server")]
        public List<ACTrack> Tracks { get; set; }

        [IniSettingsAttribute("CONFIG_TRACK", Output = "Config")]
        [DisplayName("Track Configurations")]
        [Description("subversion of the track ")]
        public List<ACTrack> TrackConfigs
        {
            get
            {
                return Tracks;
            }
        }

        [IniSettingsAttribute("SUN_ANGLE")]
        [DisplayName("Sun Angle")]
        [Description("Time of day")]
        public int SunAngle { get; set; }

        [IniSettingsAttribute("RACE_OVER_TIME")]
        [DisplayName("Race over time")]
        [Description("Time remaining in seconds to finish the race from the moment the first one passes on the finish line")]
        public int RaceOvertime { get; set; }

        [IniSettingsAttribute("VOTING_QUORUM")]
        [DisplayName("Voting Quorum")]
        [Description("Percentage of vote that is required for the vote to pass")]
        public int VotingQuorum { get; set; }

        [IniSettingsAttribute("VOTE_DURATION")]
        [DisplayName("Voting Duration")]
        [Description("Time in seconds")]
        public int VoteDuration { get; set; }

        [IniSettingsAttribute("KICK_QUORUM")]
        [DisplayName("Kick Quorum")]
        [Description("Percentage of vote that is required for the KICK vote to pass")]
        public int KickQuorum { get; set; }

        [IniSettingsAttribute("TC_ALLOWED")]
        [DisplayName("TC Allowed")]
        [Description("0 -> no car can use TC, 1 -> only car provided with TC can use it; 2-> any car can use TC")]
        public int TCAllowed { get; set; }

        [IniSettingsAttribute("ABS_ALLOWED")]
        [DisplayName("ABS Allowed")]
        [Description("0 -> no car can use ABS, 1 -> only car provided with ABS can use it; 2-> any car can use ABS")]
        public int AbsAllowed { get; set; }

        [IniSettingsAttribute("STABILITY_ALLOWED")]
        [DisplayName("Stability assist")]
        [Description("Stability assist allowed")]
        public bool StabilityAllowed { get; set; }

        [IniSettingsAttribute("AUTOCLUTCH_ALLOWED")]
        [DisplayName("Autoclutch allowed")]
        [Description("Autoclutch assist allowed")]
        public bool AutoclutchAllowed { get; set; }

        [IniSettingsAttribute("DAMAGE_MULTIPLIER")]
        [DisplayName("Damage Multiplier")]
        [Description("Damage from 0 (no damage) to 100 (full damage)")]
        public int DamageMultipier { get; set; }

        [IniSettingsAttribute("FUEL_RATE")]
        [DisplayName("Fuel Rate")]
        [Description("Fuel usage from 0 (no fuel usage) to XXX (100 is the realistic one)")]
        public int FuelRate { get; set; }

        [IniSettingsAttribute("ALLOWED_TYRES_OUT")]
        [DisplayName("Allowed Tyres Out")]
        [Description("penalty (-1 disabled)")]
        public int AllowedTiresOut { get; set; }

        [IniSettingsAttribute("TYRE_WEAR_RATE")]
        [DisplayName("Tyre Wear Rate")]
        [Description("Tyre wear from 0 (no tyre wear) to XXX (100 is the realistic one)")]
        public int TireWearRate { get; set; }

        [IniSettingsAttribute("TYRE_BLANKETS_ALLOWED")]
        [DisplayName("Allowed Tyres Out")]
        [Description("At the start of the session or after the pitstop the tyre will have the the optimal temperature")]
        public Boolean TireBlanketsAllowed { get; set; }
    }
}
